package com.elinkway.infinitemovies.bigdata;

import android.content.Context;
import android.text.TextUtils;

import com.elinkway.infinitemovies.utils.IdUtils;
import com.elinkway.infinitemovies.utils.MoviesUtils;

public class BigDataConstants {
    public static final String OS = "android";
    public static final String OSVERSION = BigDataUtils.getOSVersion();
    public static final String API_VERSION = "3.7.3";
    public static String P1 = IdUtils.BIGDATA_P1;
    public static String P2 = IdUtils.BIGDATA_P2;
    public static String P3 = IdUtils.BIGDATA_P3;
    public static String CHANNEL;
    public static String BRAND = BigDataUtils.getBrandName();
    public static String SERIAL = BigDataUtils.getDeviceName();
    public static String RESOLUTION = "android";
    public static String MAC;
    public static String VERSION;
    public static String ANDROIDID;
    public static String MD5ANDROIDID;
    public static String AUID;
    public static String APPRUNID; // 设备id _ 时间戳
    public static String SSID;
    public static String DEVICEID; // 设备id
    public static String INSTALLID;
    public static String SERIALNO;
    public static String IMEI = "";
    public static String MD5IMEI = "";
    public static String IMSI = "";
    public static String DESIMEI = "";
    public static String DESIMSI = "";
    public static String WMAC = "";
    public static String UPMD5MAC = "";

    public static String UUID; // 播放器生成唯一的UUID
    public static String CUR_URL; // 当前页面地址
    public static String PCODE; //

    public static String REID; // 推荐点击动作上报时

    public static String NT; // 网络类型

    public static String CDE_VERSION = "1.0.74"; // cde版本
    public static String CAID = IdUtils.CDE_APP_ID; // cde为每个app指定的唯一ID （快看影视 60 影视大全 700）
    public static String BD_APP_NAME = IdUtils.BIGDATA_APP_NAME;

    //AD_SHOW_AP
    public static final String AD_HOME_FOCUS_ = "ad_home_focus_";
    public static final String AD_HOME_HOT_ = "ad_home_hot_";
    public static final String _SHOW = "_show";
    public static final String ILLEGAL_REPORT_BTN_CLICK= "illegal_report_btn_click";
    public static final String ILLEGAL_REPORT_SUBMIT = "illegal_report_submit";
    public static final String AD_HOME_BANNER_SHOW = "ad_home_banner_show";
    public static final String AD_HOME_POST_SHOW = "ad_home_post_show";
    public static final String AD_CHANNEL_BANNER_SHOW = "ad_channel_banner_show";
    public static final String AD_ZT_BANNER_SHOW = "ad_zt_banner_show";
    public static final String AD_RANK_BANNER_SHOW = "ad_rank_banner_show";
    public static final String AD_DETAILS_BANNER_SHOW = "ad_details_banner_show";
    public static final String AD_START_SHOW = "ad_start_show";
    public static final String AD_SUBSCRIPTION_LIST_SHOW = "subscriptionlist_show";
    //AD_CLICK_AP
    public static final String _CLICK = "_click";
    public static final String BAIDU_AD_HOME_BANNER_CLICK = "baidu_ad_home_banner_click";
    public static final String BAIDU_AD_CHANNEL_BANNER_CLICK = "baidu_ad_channel_banner_click";
    public static final String BAIDU_AD_ZT_BANNER_CLICK = "baidu_ad_zt_banner_click";
    public static final String BAIDU_AD_RANK_BANNER_CLICK = "baidu_ad_rank_banner_click";
    public static final String BAIDU_AD_DETAILS_BANNER_CLICK = "baidu_ad_details_banner_click";
    public static final String AD_HOME_BANNER_CLICK = "ad_home_banner_click";
    public static final String AD_HOME_POST_CLICK = "ad_home_post_click";
    public static final String AD_CHANNEL_BANNER_CLICK = "ad_channel_banner_click";
    public static final String AD_ZT_BANNER_CLICK = "ad_zt_banner_click";
    public static final String AD_RANK_BANNER_CLICK = "ad_rank_banner_click";
    public static final String AD_DETAILS_BANNER_CLICK = "ad_details_banner_click";
    public static final String AD_START_CLICK = "ad_start_click";

    // ACODE
    public static final String ACODE_CLICK = "0";
    public static final String ACODE_EXPOSURE = "41";
    public static final String ACODE_LAUNCH = "11";
    public static final String ACODE_QUIT = "12";
    public static final String ACODE_PUSH = "33";

    // AP 启动类型
    public static final String AP_LAUNCH_PUSH = "push";
    public static final String AP_LAUNCH_USER = "user";
    public static final String AP_LAUNCH_BACK = "back";
    public static final String AP_LAUNCH_SHARE = "share";

    // AP key
    public static final String AP_KEY_START_TYPE = "startType";
    public static final String AP_KEY_OFF_TYPE = "offType";
    public static final String AP_KEY_TIME = "time";
    public static final String AP_KEY_AD_POS = "adPos";

    // AP 退出类型
    public static final String AP_QUIT_OFF = "off";
    public static final String AP_QUIT_BACKOFF = "backoff";

    // AP 推送Key ：类型、标题
    public static final String AP_KEY_PUSH_TYPE = "type";
    public static final String AP_KEY_PUSH_NAME = "name";

    // AP 推送值
    public static final String AP_VAL_PUSH_TYPE_ALBUM = "ablum";
    public static final String AP_VAL_PUSH_TYPE_THEME = "theme";
    public static final String AP_VAL_PUSH_TYPE_PAGE = "page";
    public static final String AP_VAL_PUSH_TYPE_ACTIVITY = "activity";
    public static final String AP_VAL_PUSH_TYPE_VIDEO = "video";

    // AR结果值
    public static final String AR_SUCCESS = "0";
    public static final String AR_FAILED = "1";

    // is login user 值
    public static final String ILU_TRUE = "0";
    public static final String ILU_FALSE = "1";

    public static final String PLAY_AC_INIT = "init";
    public static final String PLAY_AC_AD_START = "ac_start";
    public static final String PLAY_AC_AD_END = "ac_end";
    public static final String PLAY_AC_PLAY = "play";
    public static final String PLAY_AC_TIME = "time";
    public static final String PLAY_AC_BLOCK = "block";
    public static final String PLAY_AC_EBLOCK = "eblock";
    public static final String PLAY_AC_FINISH = "finish";
    public static final String PLAY_AC_BACKGROUND = "end";
    public static final String PLAY_AC_END = "end";

    public static final String PLAY_AC_TG = "tg";   //选择清晰度
    public static final String PLAY_AC_DRAG = "drag";
    public static final String PLAY_AC_PAUSE = "pa";    //暂停
    public static final String PLAY_AC_RESUME = "resume";  //暂停后恢复播放

    public static final String TY_ONLINE = "0";// 点播
    public static final String TY_TVLINE = "1";// 直播
    public static final String TY_LOCAL = "3";// 本地缓存

    public static int OWNER_IN = 1; // 乐视网自有媒资
    public static int OWNER_OUT = 0; // 外网媒资

    public static String PACKAGE_NAME;

    // errType 播放错误
    public static String PLAY_ERR = "pl";

    // errcode
    public static String ONLINE_PLAY_ERR = "0042";// 播放错误
    public static String LOCAL_PLAY_ERR = "0020";// （本地视频）视频播放失败
    public static String PARSER_DATA_ERR = "0400";// 无法解析视频数据
    public static String BLOCK_OUTTIME_ERR = "0401";// 播放卡顿超时
    public static String VIDEO_NOT_FOUND_ERR = "0402";// 视频无法找到
    public static String PLAY_OUTTIME_ERR = "0403";// 播放视频超时
    public static String PLAY_SSH_ERR = "0404";// 播放视频文件出现安全错误（No）
    public static String FILE_NOT_LEGAL_ERR = "0405";// 播放的视频文件不合法
    public static String PLAY_OTHER_ERR = "0406";// 播放视频文件其它错误
    public static String PLAY_PLS_ERR = "0407";// 当前码流不能正确播放，重试其他码流均失败
    public static String PLAY_URL_ERR = "0408";// 获取播放地址接口异常，超时，失败等原因造成的异常

    public static String PGV_CURRENT_ID_HOME = "home_page_index";
    public static String PGV_CURRENT_ID_CATEGORY = "category";
    public static String PGV_CURRENT_ID_TOPIC = "topic";
    public static String PGV_CURRENT_ID_HOT = "hot";
    public static String PGV_CURRENT_ID_RANKING = "ranking";
    public static String PGV_CURRENT_ID_SEARCH = "search";
    public static String PGV_CURRENT_ID_COLLECT = "collect";
    public static String PGV_CURRENT_ID_HISTORY = "history";
    public static String PGV_CURRENT_ID_DOWNLOAD = "download";
    public static String PGV_CURRENT_ID_MY = "my";
    public static String PGV_CURRENT_ID_EPISODES = "episodes";
    public static String PGV_CURRENT_ID_MOVIE = "movie";
    public static String PGV_CURRENT_ID_CARTOON = "cartoon";
    public static String PGV_CURRENT_ID_VARIETY = "variety";
    public static String PGV_CURRENT_ID_DOCUMENTARY = "documentary";
    public static String PGV_CURRENT_ID_DETAIL = "detail_";
    public static String PGV_CURRENT_ID_THEME = "theme_";
    public static String PGV_CURRENT_ID_DETAIL_RANKING = "_ranking";
    public static String PGV_CURRENT_ID_CATEGORY_NAVIGATOR = "category_navigator";

    public static final String MORE_FEED_RECNUM = "morefeed";

    private static final String DES_KEY = "rdgf2916@atadgib";

    //一点资讯
    public static  String PAGE_SHOW_VIDEOCLIPS = "page_show_VideoClips";
    public static  String CLICKVIDEOCLIPS = "clickVideoClips";
    public static  String CLICKVIDEOCARD = "clickVideoCard";
    public static  String YDZX_REQUEST = "ydzx_request";


    public static void init(Context applicationContext, BigDataConfig config) {
        PACKAGE_NAME = BigDataUtils.getPackageName(applicationContext);
        MAC = BigDataUtils.getMac(applicationContext);
        IMEI = BigDataUtils.getIMEI(applicationContext);
        MD5IMEI = BigDataUtils.MD5Helper(IMEI);
        IMSI = BigDataUtils.getIMSI(applicationContext);
        VERSION = BigDataUtils.getVersion(applicationContext);
        ANDROIDID = BigDataUtils.getAndroidId(applicationContext);
        if(!TextUtils.isEmpty(ANDROIDID)){
            MD5ANDROIDID = BigDataUtils.MD5Helper(ANDROIDID);
        }
        INSTALLID = BigDataUtils.getInstallid(applicationContext);
        SERIALNO = BigDataUtils.getSerialNo();
        AUID = BigDataUtils.getAUID(applicationContext);
        RESOLUTION = BigDataUtils.getResolution(applicationContext);
        P1 = config.getP1();
        P2 = config.getP2();
        P3 = config.getP3();
        CHANNEL = config.getChannel();
        APPRUNID = BigDataConstants.AUID + "_" + System.currentTimeMillis();
        SSID = BigDataUtils.getSSID(applicationContext);
        DEVICEID = MoviesUtils.getmDeviceId();

        if(!TextUtils.isEmpty(IMEI)){
            DESIMEI = BigDataUtils.desEncode(DES_KEY, IMEI.getBytes());
        }
        if(!TextUtils.isEmpty(IMSI)){
            DESIMSI = BigDataUtils.desEncode(DES_KEY, IMSI.getBytes());
        }
        if(!TextUtils.isEmpty(MAC)){
            WMAC = MAC.replace(":", "");
            UPMD5MAC = BigDataUtils.MD5Helper(WMAC.toUpperCase());
        }
    }
}
